<?php

/**
 * @author Vince Loremia 
 * @copyright 2008
 */

class LayoutPartPartGroupWidget extends Zend_Db_Table
{
	private $db;
    
    public function __construct()
    {
        $this->db= Zend_Registry::get('db');
    }
	
	public function getByPageId($pageId)
    {
    	$select = new Zend_Db_Select($this->db);
        $select
		->from (array('part' => 'part_group'),
		array ('id' => 'part.id', 'theme_id', 'widget_id', 'page_id', 'content', 'height' => 'layout.height', 'width' => 'layout.width', 'position' => 'layout.position', 'x_coordinate' => 'layout.x_coordinate', 'y_coordinate' => 'layout.y_coordinate', 'title' => 'part.title', 'source_code' => 'widget.source_code'))
		->join(array('layout' => 'layout_part'), 'layout_part_id = layout.id')
		->join(array('widget' => 'widget'), 'widget_id = widget.id')
        ->where('page_id = ?', $pageId)
        ->group('part.id');
        $stmt = $select->query();
        $result = $stmt->fetchAll();
        return $result;
    }
}


?>